/**************************************************************************** 
 * Meta，一个轻量级的静态分区Hypervisor 
 *
 * 版权(c) , 2022-
 *
 * 作者:
 *      Tupelo Shen <shenwanjiang2013@163.com>
 *
 * Meta是一个自由软件，你可以在遵循GNU GPLv2协议的条件下，重新修改并发布它。
 *
 ***************************************************************************/

#include <meta.h>
#include <cpu.h>
#include <vm.h>
#include <platform.h>

void cpu_defines() __attribute__((used));
void cpu_defines()
{
    DEFINE_SIZE(CPU_SIZE, struct cpu);

    DEFINE_OFFSET(CPU_ROOT_PT_OFF, struct cpu, root_pt);

    DEFINE_OFFSET(CPU_STACK_OFF, struct cpu, stack);
    DEFINE_SIZE(CPU_STACK_SIZE, ((struct cpu*)NULL)->stack);

    DEFINE_OFFSET(CPU_IF_OFF, struct cpu, interface);
    DEFINE_SIZE(CPU_IF_SIZE, ((struct cpu*)NULL)->interface);

    DEFINE_OFFSET(CPU_VCPU_OFF, struct cpu, vcpu);

    DEFINE_OFFSET(CPU_ARCH_OFF, struct cpu, arch);
    DEFINE_OFFSET(CPU_ARCH_OFFSTATE_OFF, struct cpu_arch, psci_off_state);
}

void vcpu_defines() __attribute__((used));
void vcpu_defines()
{
    DEFINE_SIZE(VCPU_ARCH_SIZE, struct vcpu_arch);
    DEFINE_OFFSET(VCPU_REGS_OFF, struct vcpu, regs);
    DEFINE_SIZE(VCPU_REGS_SIZE, struct arch_regs);
}

void platform_defines() __attribute__((used));
void platform_defines()
{
    DEFINE_OFFSET(PLAT_CPUNUM_OFF, struct platform_desc, cpu_num);
    DEFINE_OFFSET(PLAT_ARCH_OFF, struct platform_desc, arch);
    DEFINE_OFFSET(PLAT_ARCH_CLUSTERS_OFF, struct arch_platform, clusters);
    DEFINE_OFFSET(PLAT_CLUSTERS_CORES_NUM_OFF, struct clusters, core_num);
}